package com.mavenq.fly.utils;

public class SqlExecuteContext {
    private static final ThreadLocal<SqlExecuteStats> statsHolder = ThreadLocal.withInitial(SqlExecuteStats::new);
    
    public static SqlExecuteStats get() {
        return statsHolder.get();
    }
    
    public static void reset() {
        statsHolder.remove();
    }
    
    public static class SqlExecuteStats {
        private int executeCount;  // 执行次数
        private long totalTime;   // 总执行时间(毫秒)
        
        public void incrementCount() {
            executeCount++;
        }
        
        public void addTime(long time) {
            totalTime += time;
        }
        
        // getters
        public int getExecuteCount() {
            return executeCount;
        }
        
        public long getTotalTime() {
            return totalTime;
        }
    }
}